/**
 * 
 */
package agg;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;

/**
 * @author Hardeep
 *
 */
public class UIUtils {
	// TODO javadoc...
	public static final String res_path = "/media/ui/res/";
	public static final String icon_path = res_path + "dev_icons/";
	
	public static void addFillerLabel(Shell shell) {
		@SuppressWarnings("unused")
		Label newFiller = new Label(shell, SWT.NONE);
	}
	
	public static void addFillerLabel(Composite c) {
		@SuppressWarnings("unused")
		Label newFiller = new Label(c, SWT.NONE);
	}
	
	public static void showWarning(Shell shell, String message) {
		MessageBox messageBox =
			new MessageBox(shell,
					SWT.OK|
					SWT.CANCEL|
					SWT.ICON_WARNING);
		messageBox.setMessage(message);
		messageBox.open();
	}
	
	public static void showError(Shell shell, String message) {
		MessageBox messageBox =
			new MessageBox(shell,
					SWT.OK|
					SWT.ICON_ERROR);
		messageBox.setText("Error Encountered...");
		messageBox.setMessage(message);
		messageBox.open();
	}
	
	public static GridData createGridData(
			boolean grabHorizSpace, boolean grabVertiSpace,
			int hAlign, int vAlign,
			int hSpan, int vSpan,
			int heightHint, int widthHint,
			int hIndent, int vIndent,
			int minHeight, int minWidth) {
		GridData newData = new GridData();
		
		newData.grabExcessHorizontalSpace = grabHorizSpace;
		newData.grabExcessVerticalSpace = grabVertiSpace;
		
		newData.heightHint = heightHint;
		newData.widthHint = widthHint;
		
		if ( hAlign != -1 ) 
			newData.horizontalAlignment = hAlign;
		else
			newData.horizontalAlignment = GridData.CENTER;
		if ( vAlign != -1 ) 
			newData.verticalAlignment = vAlign;
		else
			newData.verticalAlignment = GridData.CENTER;
	
		if ( hIndent != -1 ) 
			newData.horizontalIndent = hSpan;
		else
			newData.horizontalSpan = 0;
		if ( vIndent != -1 ) 
			newData.verticalIndent = vSpan;
		else
			newData.verticalSpan = 0;
		
		if ( hSpan != -1 ) 
			newData.horizontalSpan = hSpan;
		else
			newData.horizontalSpan = 1;
		if ( vSpan != -1 ) 
			newData.verticalSpan = vSpan;
		else
			newData.verticalSpan = 1;
		
		if ( minHeight != -1 ) 
			newData.minimumHeight = minHeight;
		else
			newData.minimumHeight = 1;
		if ( minWidth != -1 ) 
			newData.minimumWidth = minWidth;
		else
			newData.minimumWidth = 1;
	
		return newData;
	}

}
